/*
 * DownloadEngineFactory.java
 *
 * Created on 12 October 2007, 14:56
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package fecchi;

import java.net.URL;
/**
 *
 * @author rcc4
 * Singleton
 */
public class DownloaderFactory {

    private static DownloaderFactory instance = null;    
    
    private DownloaderFactory(){
    }
    
    public Downloader getDownloader(TransferRequest request){
        /*TODO: use reflection here */
        if(request.getUrl().getProtocol().equalsIgnoreCase("http")){
            return new HTTPDownloader();
        }
        
        if(request.getUrl().getProtocol().equalsIgnoreCase("ftp")){
            return new FTPDownloader();
        }
        
        return null;
    }
    
    public static DownloaderFactory getInstance(){
        if(instance == null){
            instance = new DownloaderFactory();
            return instance;
        }else{
            return instance;
        }
    }
}
